package cool.webstudy.admin.controller.competition.question;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import cool.webstudy.admin.constant.enums.RoleEnum;
import cool.webstudy.admin.model.dto.competition.question.CreateCompetitionQuestionDTO;
import cool.webstudy.admin.model.dto.competition.question.PaginationQueryCompetitionQuestionInfoListDTO;
import cool.webstudy.admin.model.dto.competition.question.UpdateCompetitionQuestionDTO;
import cool.webstudy.admin.model.vo.competition.question.PaginationQueryCompetitionQuestionInfoListVO;
import cool.webstudy.admin.model.vo.competition.question.QueryCompetitionQuestionRoughInfoVO;
import cool.webstudy.admin.service.CompetitionQuestionService;
import cool.webstudy.admin.utils.aspect.logger.operation.ApiOperationLog;
import cool.webstudy.admin.utils.aspect.permissions.PermissionsCheck;
import cool.webstudy.admin.utils.aspect.request.RequestParameterCheck;
import cool.webstudy.admin.utils.common.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 莫振双
 * @date 2025/2/7 23:22
 * @description:
 */
@Tag(name = "赛题管理")
@RestController
@RequestMapping("/competition/question")
@RequestParameterCheck
public class CompetitionQuestionController {
    @Autowired
    private CompetitionQuestionService competitionQuestionService;

    @PostMapping("/create")
    @Operation(summary = "创建赛题接口")
    @ApiOperationLog(description = "创建赛题接口")
    public Result create(@RequestBody CreateCompetitionQuestionDTO createCompetitionQuestionDTO) {
        competitionQuestionService.createCompetitionQuestion(createCompetitionQuestionDTO);
        return Result.success();
    }
    @PostMapping("/update")
    @Operation(summary = "编辑赛题接口")
    @ApiOperationLog(description = "编辑赛题接口")
    public Result update(@RequestBody UpdateCompetitionQuestionDTO updateCompetitionQuestionDTO) {
        competitionQuestionService.updateCompetitionQuestion(updateCompetitionQuestionDTO);
        return Result.success();
    }
    @PostMapping("/page-query/list")
    @Operation(summary = "分页查询赛题信息列表接口")
    @PermissionsCheck(role = RoleEnum.ADMIN)
    public Result<Page<PaginationQueryCompetitionQuestionInfoListVO>> paginationQueryList(@RequestBody PaginationQueryCompetitionQuestionInfoListDTO dto){
        Page<PaginationQueryCompetitionQuestionInfoListVO> vo = competitionQuestionService.paginationQueryCompetitionQuestionInfoList(dto);
        return Result.success(vo);
    }
    @GetMapping("/query/rough-info/list")
    @Operation(summary = "获取赛题基本信息列表接口")
    public Result<List<QueryCompetitionQuestionRoughInfoVO>> queryRoughInfoList() {
        List<QueryCompetitionQuestionRoughInfoVO> vo = competitionQuestionService.queryCompetitionQuestionRoughInfoList();
        return Result.success(vo);
    }
}
